Skip to content

Conversation

@macladson
Copy link
Member

Moves the RuntimeVariableList and RuntimeFixedVector types from Lighthouse to ssz_types which is a more natural place for them to exist.

They have some additional dependencies so I have gated them behind the runtime-types feature.

@codecov
Copy link

codecov bot commented Oct 3, 2025

Codecov Report

❌ Patch coverage is 27.58621% with 84 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.00%. Comparing base (695fbf0) to head (663aaac).

Files with missing lines Patch % Lines
src/runtime_types/runtime_variable_list.rs 38.09% 52 Missing ⚠️
src/runtime_types/runtime_fixed_vector.rs 0.00% 26 Missing ⚠️
src/runtime_types/context_deserialize.rs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #67      +/-   ##
==========================================
- Coverage   57.10%   50.00%   -7.11%     
==========================================
  Files          10       13       +3     
  Lines         345      462     +117     
==========================================
+ Hits          197      231      +34     
- Misses        148      231      +83     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member Author

@macladson macladson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ready now. Although we may want to wait for the context_deserialize addition so we can combine the implementation locations

@macladson macladson mentioned this pull request Nov 11, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR moves RuntimeVariableList and RuntimeFixedVector types from the Lighthouse codebase into ssz_types, providing runtime-determined length variants of the existing compile-time length types. These types are gated behind a new runtime_types feature flag with an additional dependency on educe.

  • Introduces RuntimeVariableList<T> as a runtime equivalent to VariableList<T, N>
  • Introduces RuntimeFixedVector<T> as a runtime equivalent to FixedVector<T, N>
  • Adds support for SSZ encoding/decoding and tree hashing for RuntimeVariableList

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/runtime_types/runtime_variable_list.rs Core implementation of runtime-sized variable list with SSZ and tree hash support
src/runtime_types/runtime_fixed_vector.rs Core implementation of runtime-sized fixed vector
src/runtime_types/context_deserialize.rs Context deserialization support for RuntimeVariableList
src/runtime_types/mod.rs Module exports for the new runtime types
src/lib.rs Library integration and public API exposure behind feature flag
Cargo.toml Feature flag and dependency configuration for runtime types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

impl<T> RuntimeVariableList<T> {
/// Returns `Ok` if the given `vec` equals the fixed length of `Self`. Otherwise returns
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation is incorrect. The function accepts vectors with length <= max_len, not just those that equal a fixed length. The comment should say 'Returns Ok if the given vec length does not exceed max_len. Otherwise returns Err(OutOfBounds { .. }).'

Suggested change
/// Returns `Ok` if the given `vec` equals the fixed length of `Self`. Otherwise returns
/// Returns `Ok` if the given `vec` length does not exceed `max_len`. Otherwise returns

Copilot uses AI. Check for mistakes.

/// Returns the type-level maximum length.
///
/// Returns `None` if self is uninitialized with a max_len.
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation is incorrect. The function returns usize, not Option<usize>, so it cannot return None. Remove the line about returning None or change the return type if None is a valid state.

Suggested change
/// Returns `None` if self is uninitialized with a max_len.

Copilot uses AI. Check for mistakes.
/// let mut long: RuntimeVariableList<_> = RuntimeVariableList::new(base, 5).unwrap();
/// assert_eq!(&long[..], &[1, 2, 3, 4]);
///
/// // Push a value to if it does not exceed the maximum
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar error: remove 'to' from 'Push a value to if'. Should read 'Push a value if it does not exceed the maximum'.

Suggested change
/// // Push a value to if it does not exceed the maximum
/// // Push a value if it does not exceed the maximum

Copilot uses AI. Check for mistakes.
where
D: Deserializer<'de>,
{
// First parse out a Vec<C> using the Vec<C> impl you already have.
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment incorrectly states 'Vec' but the actual type is 'Vec'. Update comment to say 'Vec' for accuracy.

Suggested change
// First parse out a Vec<C> using the Vec<C> impl you already have.
// First parse out a Vec<T> using the Vec<T> impl you already have.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird way to phrase this, but it's right

@michaelsproul
Copy link
Member

@macladson Maybe we should address Copilot's feedback in a separate PR and merge this as-is

@macladson
Copy link
Member Author

@macladson Maybe we should address Copilot's feedback in a separate PR and merge this as-is

Yep agreed, this is just a straight rip of the Lighthouse code so it makes sense for that to be 1-to-1

}
}

// We can delete this once the upstream `vec_tree_hash_root` is modified to use a runtime max len.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we recently made this change in etheruem_ssz so this is also a good candidate for a post-merge cleanup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants